<?php //debug($ordenesTags);   ?>
<div class="grid12">
    <div class="widget">
        <div class="whead"><h6>Detalle de la orden</h6><div class="clear"></div></div>
        <div class="body" align="left">
            <h2>ORDEN DE COMPRA: <?php echo $orden['Ordene']['nombre']; ?></h2>
            <h2>Descripcion: <?php echo $orden['Ordene']['descripcion']; ?></h2>
            <h2>Fecha: <?php echo $orden['Ordene']['fecha']; ?></h2>
            <br />
            &nbsp;
            <h6>UNIDAD MONETARIA:&nbsp; <?php echo $orden['Ordene']['tipo_moneda'] ?></h6>
        </div>
    
    <table cellpadding="0" cellspacing="0" width="100%" class="tAlt">
        <tr>
            <td><b>Categoria</b></td>
            <td><?php echo $orden['Categoria']['nombre']; ?></td>
            <td><b>REVISED TOTAL</b></td>
            <td>
               <?php 
                //echo $orden['Ordene']['monto']; 
                $montoPo = $orden['Ordene']['monto'];                                     
                        $modMontoPo = $this->Number->format($montoPo, array(
                            'places' => 2,
                            'before' => ' ',
                            'escape' => false,
                            'decimals' => '.',
                            'thousands' => ','
                        ));
                        echo $modMontoPo;
               ?>
            </td>
        </tr>
        <tr>
            <td><b>Volumenes</b></td>
            <td><?php echo $orden['Ordene']['volumenes']; ?></td>
            <td><b>CAF</b></td>
            <td><?php echo $orden['Ordene']['cantidadcaf']; ?></td>
        </tr>
        <tr>
            <td><b>Original</b></td>
            <td>
                <?php
                if ($orden['Ordene']['original'] == 'S')
                {
                    echo "SI";
                } else
                {
                    echo "NO";
                }
                ?>
            </td>
            <td><b>Firmas</b></td>
            <td><?php echo $orden['Ordene']['firmasoriginal']; ?></td>
        </tr>
        <tr>
            <td><b>Copia</b></td>
            <td>
                <?php
                if ($orden['Ordene']['copia'] == 'S')
                {
                    echo "SI";
                } else
                {
                    echo "NO";
                }
                ?>
            </td>
            <td><b>Firmas</b></td>
            <td><?php echo $orden['Ordene']['firmascopia']; ?></td>
        </tr>

        <tr>
            <td><b>Proveedor</b></td>
            <td colspan="3"><?php echo $orden['Ordene']['proveedor']; ?></td>
        </tr>
        <tr>
            <td><b>Descripcion</b></td>
            <td colspan="3"><?php echo $orden['Ordene']['descripcion']; ?></td>
        </tr>
        <tr>
            <td><b>Observaciones</b></td>
            <td colspan="3"><?php echo $orden['Ordene']['observaciones']; ?></td>
        </tr>
        
    </table>
    <h4>Documentos</h4>
    
    <table cellpadding="0" cellspacing="0" width="100%" class="tAlt">
        <thead>
            <tr>
                <th scope="col">Documento</th>                
                <th scope="col">Volumen</th>
            </tr>
        </thead>
        
        <tbody>
            <?php //debug($documentos); ?>
            <?php foreach ($documentos as $d): ?>
                <tr>
                    <td>
                        <?php 
                            echo $d['documentos']['nombre']; 
                            if(($d['doc']['documento_id'] == 15) || ($d['doc']['documento_id'] == 1))
                            {
                                if($d['doc']['original']==1)
                                {
                                    echo(' - (Original)');
                                }
                            }
                        ?>
                    </td>                    
                    <td><?php echo $d['doc']['volumen']; ?></td>                    
                </tr>
            <?php endforeach; ?>
        </tbody>        
    </table>
    <h4>Tags</h4>
    
    <table cellpadding="0" cellspacing="0" width="100%" class="tAlt">
        <thead>
            <tr>
                <th scope="col">Tags</th>
                <th scope="col">Descripcion</th>
                <th scope="col">Monto</th>
            </tr>
        </thead>
        
        <tbody>
            <?php foreach ($ordenesTags as $ot): ?>
                <?php $sum = 0; ?>
                <tr>
                    <td><?php echo $ot['ot']['tag_id']; ?></td>            
                    <td>
                        <?php
                        if ($ot['tags']['descripcion1'] == NULL)
                        {
                            echo 'NO TIENE';
                        } else
                        {
                            echo $ot['tags']['descripcion1'];
                        }
                        ?>
                    </td>       
                    <td>
                        <?php //$ot['ot']['monto']; $sum += $ot['ot']['monto']; echo $sum;
                        
                        $montoTag = $ot['ot']['monto'];                                     
                        $modMontoTag = $this->Number->format($montoTag, array(
                            'places' => 2,
                            'before' => ' ',
                            'escape' => false,
                            'decimals' => '.',
                            'thousands' => ','
                        ));
                        echo $modMontoTag;
                        ?>
                    </td>
                </tr>
            <?php endforeach; ?>
        </tbody>

    </table>  
    
    <h4>Cambios de Orden</h4>
    <?php //debug($cambiosO); ?>
    <?php foreach($cambiosO as $c): ?>
    <table cellpadding="0" cellspacing="0" width="100%" class="tAlt">
        <tr>
            <td><b>Numero Cambio de Orden</b></td>
            <td>000<?php echo $c['Cambiordene']['numero']; ?></td>
            <td><b>TOTAL AMOUNT</b></td>
            <td><?php //echo $c['Cambiordene']['monto']; 
            
                    $montoCamb = $c['Cambiordene']['monto'];                                     
                    $modMontoCord = $this->Number->format($montoCamb, array(
                            'places' => 2,
                            'before' => ' ',
                            'escape' => false,
                            'decimals' => '.',
                            'thousands' => ','
                        ));
                        echo $modMontoCord;
            
            ?></td>
        </tr>
        <tr>
            <td><b>Volumen</b></td>
            <td>
                <?php 
                    if(empty($c['Cambiordene']['volumen'])){
                        echo '0';
                    }else{
                        echo $c['Cambiordene']['volumen'];
                        
                    }
                    //echo $c['Cambiordene']['volumen']; 
                ?>
            </td>
            <td><b>Fecha</b></td>
            <td><?php echo $c['Cambiordene']['fecha']; ?></td>
        </tr>
        <tr>
            <td><b>Documento Original</b></td>
            <td>
                <?php
                if ($c['Cambiordene']['original'] == 1)
                {
                    echo "SI";
                } else
                {
                    echo "NO";
                }
                ?>
            </td>
            <td><b>Cantidad de Firmas</b></td>
            <td><?php echo $c['Cambiordene']['cantforiginal']; ?></td>
        </tr>
        <tr>
            <td><b>Documento Copia</b></td>
            <td>
                <?php
                if ($c['Cambiordene']['copia'] == 1)
                {
                    echo "SI";
                } else
                {
                    echo "NO";
                }
                ?>

                <?php //echo $c['Cambiordene']['copia']; ?>
            </td>
            <td><b>Cantidad de Firmas</b></td>
            <td><?php echo $c['Cambiordene']['cantfcopia']; ?></td>
        </tr>
        <tr>
            <td><b>Observaciones</b></td>
            <td colspan="3"><?php echo $c['Cambiordene']['observaciones']; ?></td>
        </tr>
    </table>
    <?php endforeach; ?>
    </div>
</div>

<div class="actions-right">
            <?php echo $this->Html->link("Volver &raquo;", array('controller'=>'Ordenes', 'action'=>'index'), array('class'=>'buttonS bLightBlue', 'escape' => FALSE)); ?>
</div>